package com.headwind.logistics.report.controller;

import com.headwind.logistics.common.util.LayuiUtil;
import com.headwind.logistics.report.dto.CityOwnerdto;
import com.headwind.logistics.report.service.inter.CityServiceInter;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Administrator
 * @Date 2020/7/24 0024 17:17
 * @Version 1.0
 * @DESCRIPTION 填写类作用描述
 *
 */
@Controller
public class CityController {
    @Resource
    private CityServiceInter cityServiceInter;

    @ResponseBody
    @GetMapping("/admin/report/queryAllCityOwnerdto")
    public LayuiUtil queryAllCityOwnerdto(Integer page, Integer limit) {

        List<CityOwnerdto> list = cityServiceInter.queryAllCityOwnerdto(page, limit);

        Integer count = cityServiceInter.cityOwnerdtoss();

        //System.out.println("差烦恼" + list.size());

        return LayuiUtil.data(count,list);
    }

    /**
     * 根据ID删除
     * @param id
     * @return
     */
    @RequestMapping("/admin/return/deleteowner")
    @ResponseBody
    public int deleteOwner(int id){
       // System.out.println("是的法规和"+id);
        int cout = cityServiceInter.deleteOwner(id);

        return cout;
    }

    @RequestMapping("/admin/report/addOwner")
    @ResponseBody
    public int addCoupon(CityOwnerdto cityOwnerdto){
        System.out.println("进来了"+cityOwnerdto.getName());
        int count = cityServiceInter.addOwner(cityOwnerdto);
        if (count>0){
            System.out.println("新增成功");
        }else{
            System.out.println("新增失败");
        }
        return count;
    }

    /**
     * 修改货主信息
     * @param cityOwnerdto
     * @return
     */
    @RequestMapping("/admin/report/updateOwner")
    @ResponseBody
    public int updateOwner(CityOwnerdto cityOwnerdto){
      int count = cityServiceInter.updateOwner(cityOwnerdto);
        if (count>0){
            System.out.println("修改成功");
        }else{
            System.out.println("修改失败");
        }
        return count;
    }
}